home *** CD-ROM | disk | FTP | other *** search
- ; --------------------------------------------------------------------------------------
- ;
- ; MESG.ASM
- ; By Ben Manuto
- ;
- ; Assembly glue to hook into the Messaging system Interface.
- ;
- ; c.1996, by Apple Computer, Inc. All rights reserved.
- ;
- ; --------------------------------------------------------------------------------------
-
- INCLUDE MSG.INC
-
-
- MsgAvailable PROTO FAR C
- MsgRegister PROTO FAR C msgSel:DWORD, msgCount:WORD, msgCmmd:WORD
- MsgSend PROTO FAR C msgPBlk:DWORD
-
- MsgInstHandler PROTO FAR C msgRecElem:DWORD
- MsgRmvHandler PROTO FAR C msgRecElem:DWORD
-
- MsgReceive PROTO FAR C msgPBlk:DWORD
- MsgHandler PROTO FAR C
-
- _TEXT SEGMENT PUBLIC 'CODE'
- .486
-
- ; --------------------- DATA ------------------------
-
- msgReceiveSegment WORD ? ; gobal to msgPBlk (msgReceiveSegment:msgReceiveOffset)
- msgReceiveOffset WORD ?
-
-
-
- ;------------------------------------------------------------------------------
-
- MsgAvailable PROC FAR C
-
- mov ah,rsIsAvailable
- int MsgCall
-
- ret
-
- MsgAvailable ENDP
-
-
- ;------------------------------------------------------------------------------
-
- MsgRegister PROC FAR C msgSel:DWORD, msgCount:WORD, msgCmmd:WORD
-
- mov ebx,msgSel
- mov cx,msgCount
- mov ah,rsRegisterMessage
- int MsgCall
-
- mov dx,bx
- mov bx,msgCmmd
- mov [bx],dx
- ret
-
-
- MsgRegister ENDP
-
-
- ;------------------------------------------------------------------------------
-
- MsgSend PROC FAR C msgPBlk:DWORD
-
- les bx,msgPBlk ; Load the msgPBlk into es:bx
- mov ah,rsSendMessage
- int MsgCall ; Send it to the Mac.
-
- ret
-
- MsgSend ENDP
-
-
- ;------------------------------------------------------------------------------
-
- MsgInstHandler PROC FAR C msgRecElem:DWORD
-
- les bx,msgRecElem
- mov ah,rsInstallMsgHandler
- int MsgCall
-
- sub ax,ax
- ret
-
- MsgInstHandler ENDP
-
-
- ;------------------------------------------------------------------------------
-
- MsgRmvHandler PROC FAR C msgRecElem:DWORD
-
- mov ah,rsRemoveMsgHandler
- les bx,msgRecElem ; load the msgRecElem into es:bx
- int MsgCall ; Call the message system to remove it.
-
- sub ax,ax
- ret
-
- MsgRmvHandler ENDP
-
-
- ;------------------------------------------------------------------------------
-
- MsgReceive PROC FAR C msgPBlk:DWORD
-
- les bx,msgPBlk ; Load MsgPBlk into es:bx.
- mov es:MsgPBlk.msgResult[BX],1 ; Set it to busy.
-
- mov cs:[msgReceiveSegment], 0 ; Set our global to NULL.
- mov cs:[msgReceiveOffset], 0
-
- cmp es:MsgPBlk.msgBuffer[bx], 0 ; Is the msgBuffer NULL?
- jz exit ; If so, get out.
-
- mov cs:[msgReceiveOffset],bx ; If not, save the ptr for the receiver routine.
- mov bx,es
- mov cs:[msgReceiveSegment],bx
- xor ax,ax
-
- exit:
- ret
-
- MsgReceive ENDP
-
-
- ;------------------------------------------------------------------------------
- ; If there is data attached to this message, then return (in es:bx) a pointer to MsgPBlock.
- ; If the message is contained solely in param1 and param2 (ie no buffer) return es:bx as NULL.
-
-
- MsgHandler PROC FAR C
-
- cmp ax, ds:MsgRecElem.cmdBase[di] ; compare current msgCmd and cmdBaseID
- jg setAck ; Set the Ack flag and bail..
-
- mov bx, cs:msgReceiveSegment ; Check msgReceive (our MsgPBlk) for null?
- or bx, cs:msgReceiveOffset
- jz nope ; if null, bail.
-
- mov bx, cs:msgReceiveSegment ; otherwise, load es:bx with msgReceive pointer
- mov es, bx
- mov bx, cs:msgReceiveOffset
- retf ; return
-
- setAck:
- les bx, ds:MsgRecElem.userData[di] ; load ES:BX with a pointer to the AckInfo structure.
- mov es:AckInfo.bytesReceived[bx], ecx ; load bytesRecevied with ECX (param1).
- mov es:AckInfo.ackReceived[bx], 1 ; Mark that the ack was received.
-
- nope:
- xor bx, bx ; Clear BX.
- mov es, bx ; Put bx in es.
- retf
-
- MsgHandler ENDP
-
-
- _TEXT ENDS
-
- END
-
-